<?php
/**
 * Galdic project
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Galdic
 * @package    Galdic
 * @copyright  Copyright (c) 2009 vifito (http://vifito.eu)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Admin_Form_Definition
 * 
 * @package    Galdic
 * @copyright  Copyright (c) 2009 vifito (http://vifito.eu)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Definition.php 1 2009-09-13 00:06:15Z vifito $
 */
class Admin_Form_DefinitionDialog extends Zend_Form
{
    public function init()
    {
        Zend_Dojo::enableForm($this);
    }
    
    public function __construct($options=null)
    {
        parent::__construct($options);        
        
        $this->setName('definitionDialog')
             ->setAttrib('id', 'definitionDialog');
             
        
        $id_def = new Zend_Form_Element_Hidden('id_def');        
        
        $content = new Zend_Dojo_Form_Element_Editor('content');
        $content->setRequired(true)
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setAttrib('dojoType', 'dijit.Editor')
                ->setAttrib('height', '100');
        
        $etymology = new Zend_Dojo_Form_Element_TextBox('etymology');
        $etymology->setLabel('Etimoloxía: ')
                  ->addFilter('StripTags')
                  ->addFilter('StringTrim')
                  ->setAttrib('dojoType', 'dijit.form.TextBox');
        
        $category_id = new Zend_Dojo_Form_Element_FilteringSelect('category_id');
        $categories  = new Admin_Model_DbTable_Categories();
        $category_id->addMultiOptions( $categories->getHtmlOptions() );
        $category_id->setLabel('Categoría/Familia: ')
                    ->setRequired(true)
                    ->setAttrib('dojoType', 'dijit.form.FilteringSelect');        
        
        $submit = new Zend_Dojo_Form_Element_Button('submitBtn');
        $submit->setLabel('Anexar')
               ->setAttrib('onClick', 'df.attachDefinition()')
               ->setAttrib('dojoType', 'dijit.form.Button');
        
        $this->addElements(array($content, $etymology, $category_id, $submit, $id_def));
    }        
}
